package com.twu.biblioteca.util;

import com.twu.biblioteca.exception.InvalidSelectionException;
import com.twu.biblioteca.user.UserInfo;

import java.util.HashMap;

public class Validator {
    public static String[] OPTIONS = {"1", "2", "3", "4","6"};

    public boolean validateOption(String option) throws InvalidSelectionException {
        for (String optionIn : OPTIONS) {
            if (optionIn.equals(option)) {
                return true;
            }
        }
        throw new InvalidSelectionException(InvalidSelectionException.INVALID_OPTION);
    }

    public static boolean validateUserLogInState() {
        HashMap<String,UserInfo> users = UserInfo.getUsers();
        for(UserInfo userInfo: users.values()){
            if(userInfo.isLoggedIn()){
                return true;
            }
        }
        return false;
    }
}
